﻿Imports System.Data.OleDb

Public Class ThoiKhoaBieuDAO
    Public Shared Function SelectAll() As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu"
        Dim dt As DataTable
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Sub Insert(ByVal _tkb As ThoiKhoaBieuDTO)
        Dim strSQL As String = "Insert into ThoiKhoaBieu(Malop,Tenlop,Hoten,Tenmon,Sohieuphong,Hocky,Ngay,Buoi,Namhoc) Values(N'" & _tkb.MaLop & "',N'" & _tkb.TenLop & "',N'" & _tkb.HoTen & "',N'" & _tkb.TenMon & "',N'" & _tkb.SoHieuPhong & "',N'" & _tkb.HocKy & "',N'" & _tkb.Ngay & "',N'" & _tkb.Buoi & "',N'" & _tkb.NamHoc & "')"
        SQLProvider.ExecNoneQuery(strSQL)

    End Sub
    Public Shared Sub Delete(ByVal _tkb As ThoiKhoaBieuDTO)
        Dim strSQL As String = "delete from ThoiKhoaBieu where MaTKB = N'" & _tkb.MaTKB & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Sub Update(ByVal _tkb As ThoiKhoaBieuDTO)
        Dim strSQL As String = "Update ThoiKhoaBieu set Malop = N'" & _tkb.MaLop & "',Tenlop = N'" & _tkb.TenLop & "', Hoten = N'" & _tkb.HoTen & "', Tenmon = N'" & _tkb.TenMon & "', Sohieuphong = N'" & _tkb.SoHieuPhong & "', Hocky = N'" & _tkb.HocKy & "', Ngay = N'" & _tkb.Ngay & "', Buoi = N'" & _tkb.Buoi & "', Namhoc = N'" & _tkb.NamHoc & "' where MaTKB = N'" & _tkb.MaTKB & "'"
        SQLProvider.ExecNoneQuery(strSQL)
    End Sub
    Public Shared Function SelectByTKB(ByVal _tkb As ThoiKhoaBieuDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu where Ngay = '" & _tkb.Ngay & "'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function

    Public Shared Function SelectMaLopByTenLop(ByVal _tkb As ThoiKhoaBieuDTO) As String
        Dim iMaLop As String
        Dim strSQL As String = "select * from Lop  where Tenlop like N'%" & _tkb.TenLop & "%'"
        Dim dt As DataTable = SQLProvider.ExecQuery(strSQL)
        Dim n As Integer = dt.Rows.Count
        If n > 0 Then
            iMaLop = dt.Rows(0).Item("MaLop")
        End If
        Return iMaLop
    End Function
    Public Shared Function SelectSoSVByTenLop(ByVal _tkb As ThoiKhoaBieuDTO) As Integer
        Dim iSiSo As Integer
        Dim strSQL As String = "select * from Lop  where Tenlop like N'%" & _tkb.TenLop & "%'"
        Dim dt As DataTable = SQLProvider.ExecQuery(strSQL)
        Dim n As Integer = dt.Rows.Count
        If n > 0 Then
            iSiSo = dt.Rows(0).Item("Sosv")
        End If
        Return iSiSo
    End Function
    Public Shared Function SelectSucChuaByTenPhong(ByVal _tkb As ThoiKhoaBieuDTO) As Integer
        Dim iSucChua As Integer
        Dim strSQL As String = "select * from PhongHoc where SoHieuPhong like N'%" & _tkb.SoHieuPhong & "%'"
        Dim dt As DataTable = SQLProvider.ExecQuery(strSQL)
        Dim n As Integer = dt.Rows.Count
        If n > 0 Then
            iSucChua = dt.Rows(0).Item("Succhua")
        End If
        Return iSucChua
    End Function
    Public Shared Function TKBTheoGV(ByVal _gv As ThoiKhoaBieuDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu where Hoten like N'%" & _gv.HoTen & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Function TKBTheoLop(ByVal _lop As ThoiKhoaBieuDTO) As DataTable
        Dim dt As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu where Tenlop like N'%" & _lop.TenLop & "%'"
        dt = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Function KiemTraThem(ByVal _tkb As ThoiKhoaBieuDTO) As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu where Tenlop like N'%" & _tkb.TenLop & "%' or Hoten like N'%" & _tkb.HoTen & "%' and Ngay = '" & _tkb.Ngay & "'"
        Dim dt As DataTable = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
    Public Shared Function KiemTra(ByVal _tkb As ThoiKhoaBieuDTO) As DataTable
        Dim strSQL As String = "select * from ThoiKhoaBieu where Sohieuphong like N'%" & _tkb.SoHieuPhong & "%' and Buoi like N'%" & _tkb.Buoi & "%' and Ngay = '" & _tkb.Ngay & "'"
        Dim dt As DataTable = SQLProvider.ExecQuery(strSQL)
        Return dt
    End Function
End Class
